package com.leon.learnenginespace.drools.utils.operation.impl;

import com.leon.learnenginespace.drools.utils.operation.IOperationBase;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 包含
 * @author DJ032474
 */
@Component
public class ContainsOperation implements IOperationBase {
    /**
     * v[1]包含v[2]
     * @param v
     * @return
     */
    @Override
    public Boolean operation(String dataType,Object ...v) {
        try {
            Object v1 = v[0];
            Object v2 = v[1];
            if(v1 == null){
                return false;
            }
           List<?> listV1 = (List<?>) v1;
           return listV1.contains(v2);
       }catch (Exception e){
           return false;
       }
    }
}
